var app = getApp();
var $ = require("../../utils/httpHelper.js")
Page({

  /**
   * 页面的初始数据
   */
  data: {
    objarr: [],
    page: 1,
    pagesize: 5,
    totalpage: 0,//最大页数
    height: 0,
    nomore: true,
    del: false,
    currentTab: 0,
    types:1
  },
  
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var self = this;
    wx.getSystemInfo({
      success: function (res) {
        console.log(res);
        self.setData({ height: res.windowHeight})
      }
    })
    this.getData()

  },
  //滑动到底部 上拉加载
  scrollBottom: function () {
    this.data.page++
    if (this.data.page > this.data.totalpage) {
      this.setData({
        nomore: false
      })
    } else {
      let params = {
        rd_session: app.globalData.userInfo.rd_session,
        page: this.data.page,
        page_size: this.data.pagesize,
      }
      $.httpPost("member_class", params, (data, err) => {
        let arr = this.data.objarr;
        for (let item of data.data.list) {
          arr.push(item);
        }
        this.setData({
          objarr: arr
        })
      })


    }

  },
  getData(){
    let params = {
      rd_session: app.globalData.userInfo.rd_session,
      page: this.data.page,
      page_size: this.data.pagesize
    }
    $.httpPost("member_class", params, (data, err) => {
      this.setData({
        objarr: data.data.list,
        totalpage: data.data.total_page
      })
    })
  },
  tochannel(e){
    let id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '/pages/class/channel?id='+id,
    })
  }
})